package com.th.therp.controller;

import com.th.therp.pojo.dto.page.InventoryPageQueryDTO;
import com.th.therp.pojo.result.PageResult;
import com.th.therp.pojo.result.Result;
import com.th.therp.pojo.vo.MaterialOptionsVo;
import com.th.therp.service.InventoryService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 库存请求控制器
 */
@Log4j2
@RestController
@RequestMapping("/inventory")
public class InventoryController {

    @Autowired
    private InventoryService inventoryService;

    @GetMapping("/page")
    @ResponseBody
    public Result<PageResult> page(InventoryPageQueryDTO inventoryPageQueryDTO){
        log.info("库存分页查询:{}",inventoryPageQueryDTO);
        PageResult pageResult = inventoryService.page(inventoryPageQueryDTO);
        return Result.success(pageResult);
    }

    //根据仓库Id查询商品选择列表
    @GetMapping("/findMaterialOptionsByStoreId")
    @ResponseBody
    public Result<List<MaterialOptionsVo>> findMaterialOptionsByStoreId(Integer storeId){
        log.info("根据仓库Id返回商品选择列表:{}",storeId);
        List<MaterialOptionsVo> materialOptionsVoList = inventoryService.findMaterialOptionsByStoreId(storeId);
        return Result.success(materialOptionsVoList);
    }

}
